home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / lastrun.arc / LASTRUN.ASM next >
Assembly Source File  |  1986-10-17  |  8KB  |  230 lines

  1.           page 60,132
  2.           ;Copyright 1986 Arnold Bernard Krueger
  3.           ;               all rights reserved
  4.           ;               1600 Prestwick
  5.           ;               Grosse Pointe Woods, MI, 48236
  6.           ;               313-881-4829 (voice)
  7.  
  8.           ;program to check file specified for current date
  9.  
  10.           ; Usage is: LASTRUN filename.ext
  11.  
  12.           ;           filename.ext must exist and be 4 bytes long
  13.           ;           initially, both words should be zeros
  14.  
  15.           ;if file is current,       return errorlevel=0
  16.           ;if file is in the past,   return errorlevel=1, and update it
  17.           ;if file is in the future, return errorlevel=2
  18.  
  19.           ;create  argument file as follows:
  20.  
  21.           ; DEBUG filename.ext      
  22.           ;                          run DEBUG.COM . File shouldn't be found
  23.           ; E 100                   ;enter data into file
  24.           ; 00 00 00 00             ;make first four bytes zero
  25.           ; RCX                     ;set length
  26.           ; 4                       ;to be four
  27.           ; W                       ;write file out
  28.           ; Q                       ;and quit
  29.           ; LASTRUN  filename.ext   ;make it current
  30.  
  31.  
  32. code_seg  segment
  33.           assume    cs:code_seg
  34.           assume    ds:code_seg
  35.           assume    es:code_seg
  36.           org       80h
  37. parmlistl db        0          ;parameter list length from DOS
  38. parmlist  db        0          ;parameter list from DOS
  39.           org       0b0h
  40. handle    dw        0          ;file handle for I/O
  41. asciiz    db        0          ;work area carved out of parm area
  42.           org       100h
  43. first:
  44. code      proc      far
  45.           JMP       start       ;branch past data
  46.           db        'Copyright 1986, Arnold b. Krueger'
  47. cr        equ       0dh
  48. lf        equ       0ah
  49.  
  50. msgtxt1   db cr,lf,'Usage is: LASTRUN filespec  -to check date file',cr,lf,'$'
  51. msgtxt2   db 'Argument File not found',cr,lf,'$'
  52. msgtxt3   db 'File open error',cr,lf,'$'
  53. msgtxt4   db 'File read error',cr,lf,'$'
  54. msgtxt5   db 'Time error',cr,lf,'$'
  55. msgtxt6   db 'File point error',cr,lf,'$'
  56. msgtxt7   db 'File write error',cr,lf,'$'
  57. msgtxt8   db 'File close error',cr,lf,'$'
  58.  
  59. msglist   dw  msgtxt1-code_seg
  60.           dw  msgtxt2-code_seg
  61.           dw  msgtxt3-code_seg
  62.           dw  msgtxt4-code_seg
  63.           dw  msgtxt5-code_seg
  64.           dw  msgtxt6-code_seg
  65.           dw  msgtxt7-code_seg
  66.           dw  msgtxt8-code_seg
  67.  
  68. date_rec  dw 0,0                      ;date from file  0YYY MMDD
  69.  
  70. date_now  dw 0,0                      ;current date    0YYY MMDD
  71.  
  72. errmsg1:      
  73.               MOV  AL,10h
  74.               JMP  exitmsg    
  75. errmsg2:      
  76.               MOV  AL,11h
  77.               JMP  exitmsg    
  78. errmsg3:      
  79.               MOV  AL,12h
  80.               JMP  exitmsg    
  81. errmsg4:      
  82.               MOV  AL,13h
  83.               JMP  exitmsg    
  84. errmsg5:      
  85.               MOV  AL,14h
  86.               JMP  exitmsg    
  87. errmsg6:      
  88.               MOV  AL,15h
  89.               JMP  exitmsg    
  90. errmsg7:      
  91.               MOV  AL,16h
  92.               JMP  exitmsg    
  93. errmsg8:      
  94.               MOV  AL,17h
  95.               JMP  exitmsg    
  96.  
  97.  
  98. start:       
  99.               MOV  SI,offset parmlistl  ;point to parmlist length        
  100.               MOV  DI,offset asciiz     ;point to AZCIIZ we build
  101.               XOR  CX,CX                ;clear CX
  102.               MOV  CL,[SI]              ;get length
  103.               INC  SI
  104.               CMP  CL,00h               ;is length zero?
  105.               JNZ  Charloop             ;if not, check on                
  106.               JMP  errmsg1              ;otherwise, complain              
  107. Charloop:     
  108.               LODSB                            
  109.               CMP  AL,' '               ;strip off leading blanks
  110.               JBE  Nextchar                              
  111.               CMP  AL,'a'               ;make file name upper case
  112.               JB   Gotchar                               
  113.               CMP  AL,'z'      
  114.               JBE  Casechar                               
  115.               JMP  Gotchar                               
  116.  
  117. Casechar:     AND   Al,0ffh-20h         ;make upper case
  118.  
  119. Gotchar:      STOSB                    
  120.  
  121. Nextchar:     LOOP Charloop
  122.  
  123.               MOV  BYTE PTR [DI],00h    ;put fence on ASCIIZ            
  124.               MOV  DX,offset asciiz                            
  125.               CLC                       ;clear the carry flag
  126.                    
  127.               MOV  AX,4E00h             ;find first
  128.               MOV  CX,0021h             ;desired attributes
  129.               INT  21h
  130.               CMP  AL,00h               ;check success
  131.               JZ   open
  132.               JMP  errmsg2                              
  133.  
  134.  
  135. open:
  136.               MOV  DX,offset asciiz
  137.               MOV  AX,3D02h        ;open for read/write
  138.               INT  21h
  139.               JC   errmsg3
  140.               MOV  handle,AX       ;save handle
  141.  
  142.               MOV  BX,handle       ;get handle
  143.               MOV  CX,4            ;get 4 bytes (yyyymmdd)
  144.               MOV  DX,offset date_rec
  145.               MOV  AH,3Fh          ;read a record
  146.               INT  21h
  147.               JC   errmsg4
  148.  
  149.               MOV  AH,2Ah          ;get DOS date cx=yyy, dh=mm, dl=dd   
  150.               INT  21h    
  151.               JC   errmsg5
  152.  
  153.               MOV  date_now,CX     ;save yyy
  154.               MOV  date_now+2,DX   ;save mmdd
  155.  
  156.               CMP  CX,date_rec     ;compare date_rec to current year
  157.               JZ   check_day
  158.               JB   future          ;date_rec is in the future
  159.               JMP  past
  160. check_day:
  161.               CMP  DX,date_rec+2   ;compare date_rec to current mmdd
  162.               JZ   now
  163.               JB   future          ;date_rec is in the future
  164.  
  165. past:
  166.               MOV  BX,handle       ;get handle
  167.               XOR  CX,CX           ;offset is zero
  168.               XOR  DX,DX
  169.               
  170.               MOV  AX,4200h        ;set offset from start of file
  171.               INT  21h
  172.               JNC  write
  173.               JMP  errmsg6
  174.  
  175.  
  176. write:
  177.               MOV  BX,handle       ;get handle
  178.               MOV  CX,4            ;write 4 bytes (yyyymmdd)
  179.               MOV  DX,offset date_now
  180.               MOV  AH,40h          ;write a record
  181.               INT  21h
  182.               MOV  AL,1
  183.               JNC  goodexit
  184.               JMP  errmsg7  
  185.  
  186. now:          MOV  AL,0            ;if file has current date
  187.               JMP  goodexit        ;   then close it and exit
  188.  
  189. future:       MOV  AL,2            ;if file date > current date
  190.               JMP  goodexit        ;   the clock might be broke
  191.  
  192. goodexit:
  193.               PUSH AX              ;save errorlevel
  194.               MOV  AX,handle
  195.               MOV  AH,3Eh          ;close file
  196.               INT  21h
  197.               POP  AX              ;restore errorlevel
  198.               JNC  exit            ;if no errors, exit
  199.               JMP  errmsg8 
  200.  
  201.  
  202. exitmsg:
  203.               PUSH AX              ;save errorlevel
  204.               SUB  AX,10h          ;reduce to offset 
  205.               SHL  AX,1            ;multiply by 2 to get words
  206.               ADD  AX,offset msglist
  207.               MOV  SI,AX           ;get address of msg address
  208.               MOV  DX,[SI]         ;get msg address
  209.  
  210.               MOV  AH,09h          ;send out some text
  211.               INT  21h
  212.               POP  AX              ;restore errorlevel
  213.  
  214. exit:         
  215.               MOV  AH,4Ch          ;terminate process
  216.               INT  21h                                 
  217.  
  218. code          ENDP
  219. code_seg      ENDS
  220.               END  first
  221.  
  222.  
  223. 
  224.  
  225.  
  226.  
  227. ┬Uï∞ï^Çuât╕=PΦ╒ûïσ]┬Uï∞ï^÷G@tï_Çu╕>PΦ│ûïσ]┬Uï∞╕ÉPΦá√ïσ]├Uï∞╞µ╞║Φ±┤╞ Ç>⌠t0ïD'èÿ=:tJ==tΦ0δ D'ïóÇ?uΦoûδΦWÉ╞ Ç> tΘ─Ç>⌠t> 6ó╕PΦƒ
  228. └t/Φ■RΘ¿ D'ïóÇ?uΦ/ûδÇ>⌠t ╕  P╕PΦ≥Φh┤δ▒Ç>⌠t% 6ó╕0PΦZ
  229. └tï╚ÇuΦ    ΘYΦM ΘS 6ó╕b"P╕V PΦƒ └uΘ▄Ç>⌠uÇ>V tÇ>V t
  230. Ç>b":tΘáb"ÿ=@vΘ└ô. ºP╕ D' D'ΦyzïD'èÿï╪÷çtΦî╖ïD'Ç?,t▌ΘαΦì}Θ┌Φ╧}Θ╘ΦÖ_Θ╬Φ≤}Θ╚Φ╒_Θ┬